package cn.jjxx.modules.sys.service.impl;

import java.util.Arrays;
import java.util.List;

import cn.jjxx.core.common.service.impl.CommonServiceImpl;
import cn.jjxx.modules.sys.mapper.ReportMapper;
import cn.jjxx.modules.sys.entity.Report;
import cn.jjxx.modules.sys.entity.ReportOrg;
import cn.jjxx.modules.sys.service.IReportService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**   
 * @Title: 报表管理
 * @Description: 报表管理
 * @author zcg
 * @date 2018-05-23 08:19:38
 * @version V1.0   
 *
 */
@Transactional
@Service("reportService")
public class ReportServiceImpl  extends CommonServiceImpl<ReportMapper,Report> implements  IReportService {

	@Override
	public boolean bindOrg(String id, String[] orgIds) {
		List<String> orgList = Arrays.asList(orgIds);
		try {
			//删除报表组织
			baseMapper.deleteOrgReport(id);
			//新增报表组织
			if(orgList.size()>0){
				baseMapper.insertOrgReport(id,orgList);
			}
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public Report findReportByOrgNumber(String reportNumber, String orgId) {
		return baseMapper.findReportByOrgNumber(reportNumber, orgId);
	}

	@Override
	public Report findReportByMenu(String menuId, String orgId) {
		return baseMapper.findReportByMenu(menuId, orgId);
	}

	@Override
	public List<ReportOrg> findOrgReport(String reportId) {
		return baseMapper.findOrgReport(reportId);
	}

}
